<?php
/**
 * ShopEx licence
 *
 * @copyright  Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn)
 * @license  http://ecos.shopex.cn/ ShopEx License
 */
class ome_ctl_admin_lmparam extends desktop_controller{
    
    var $workground = 'ome_ctl_admin_lmparam';
    var $pagelimit = 10;
    var $lmparam_model ;
    public function __construct($app)
    {
        parent::__construct($app);
        $this->member_model = $this->app->model('lmparam');
        header("cache-control: no-store, no-cache, must-revalidate");
    }
   function index(){
   	
        $custom_actions[] = array('label'=>app::get('ome')->_('添加参数'),'href'=>'index.php?app=ome&ctl=admin_lmparam&act=add_page','target'=>'dialog::{title:\''.app::get('ome')->_('添加参数').'\',width:460,height:240}');

        $actions_base['title'] = app::get('ome')->_('理文参数配置');
        $actions_base['actions'] = $custom_actions;
        $actions_base['allow_detail_popup'] = true;
        $actions_base['use_buildin_set_tag'] = false;
        $actions_base['use_buildin_export'] = false;
        $actions_base['use_buildin_filter'] = false;

        $actions_base['use_view_tab'] = false;

        $this->finder('ome_mdl_lmparam',$actions_base);
    }


    function add_page(){
        $member_lv=$this->app->model("lmparam");
        $this->display('admin/lmparam/new.html');
    }

    function add(){
        $lmparam_model = $this->app->model('lmparam');

        $arr_order['pam_account']['code'] = $_POST['pam_account']['code'];
        $arr_order['pam_account']['name'] = $_POST['pam_account']['name'];
        $arr_order['pam_account']['param'] = $_POST['pam_account']['param'];
        $arr_order['pam_account']['remark'] = $_POST['pam_account']['remark'];
        if($_POST)
        {
            if($_POST['pam_account']['id'] != '')
            {
                // 修改
                $this->begin();

                $db = kernel::database();
                $db->beginTransaction();

                        ;
                if( $lmparam_model->update($arr_order['pam_account'], array('id' => $_POST['pam_account']['id'])) )
                {
                    $db->commit();
                }else{
                    $msg = '保存失败，请联系客服!';
                    return false;
                }
                $this->end(true, app::get('ome')->_('添加成功！'));
            } 
            else 
            {
                // 添加
                $this->begin();
                $db = kernel::database();
                $db->beginTransaction();
                if( $lmparam_model->save($arr_order['pam_account']) )
                {
                    $db->commit();
                }else{
                    $msg = '保存失败，请联系客服!';
                    return false;
                }
                $this->end(true, app::get('ome')->_('添加成功！'));
            }
        }
    }
    function lmedit(){
        $lmparam = '';
        if(isset($_GET['id'])){
            $id = $_GET['id'];
            $lmparam_obj = kernel::single('ome_mdl_lmparam');
            $lmparam = $lmparam_obj->getList('*', array('id'=>$id), 0, 1);

        }
        $this->pagedata['pam_account'] = $lmparam[0];
        $this->page('admin/lmparam/new.html');

    }

    //理文测试
    
}
